﻿@using OA.Model
@using OA.AspNetCore.Html
@model OA.Model.Notice
@{

    Layout = null;
    string msg = ViewBag.Msg;
    string tips = string.Empty;
    if (!string.IsNullOrWhiteSpace(msg))
    {
        tips = $"layer.msg('{msg}');";
    }
}
<link rel="stylesheet" type="text/css" href="@ViewBag.OssUrl/front/webuploader/webuploader.css">
<script type="text/javascript" src="@ViewBag.OssUrl/front/webuploader/webuploader.js"></script>
<div class="myMenu">
    <div class="menu_left"><div class="here w1200"><a href="/Member/Home">首页</a>&nbsp;&gt;&gt;&nbsp;<a href="/Management/Notice">通知管理</a>&nbsp;&gt;&gt;&nbsp;编辑通知</div></div>
</div>
<div class="layui-my-content">
    <div class="myForm">
        @using (Html.BeginForm(FormMethod.Post, htmlAttributes: new { @class = "layui-form", id = "myForm" }))
        {
            @Html.AntiForgeryToken()

            <div class="layui-form-item">
                @Html.LabelFor(model => model.Title, new { @class = "layui-form-label" })
                <div class="layui-input-block">
                    @Html.HiddenFor(model => model.ID)
                    @Html.MyEditorFor(model => model.Title)
                </div>
            </div>

            <div class="layui-form-item">
                @Html.LabelFor(model => model.Type, new { @class = "layui-form-label" })
                <div class="layui-input-block">
                    @Html.MyEditorFor(model => model.Type)
                </div>
            </div>

            <div class="layui-form-item">
                @Html.LabelFor(model => model.SendTime, new { @class = "layui-form-label" })
                <div class="layui-input-block">
                    @Html.MyEditorFor(model => model.SendTime)
                </div>
            </div>

            <div class="layui-form-item">
                @Html.LabelFor(model => model.IsTop, new { @class = "layui-form-label" })
                <div class="layui-input-block">
                    @Html.MyEditorFor(model => model.IsTop)
                </div>
            </div>

            <div class="layui-form-item">
                @Html.LabelFor(model => model.Attachment, new { @class = "layui-form-label" })
                <div class="layui-input-block">
                    @Html.MyEditorFor(model => model.Attachment)
                </div>
            </div>

            <div class="layui-form-item">
                @Html.LabelFor(model => model.Content, new { @class = "layui-form-label" })
                <div class="layui-input-block">
                    @Html.MyEditorFor(model => model.Content)
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="submit" value="提 交" class="layui-btn mySubmit" />
                </div>
            </div>
        }
    </div>
</div>
<script type="text/javascript">
    layui.use(['form', 'layedit', 'element','layer'], function () {
		form = layui.form;
        layer = layui.layer;
        element = layui.element;
        @Html.Raw(tips)
    });
    var myFrom = $("#myForm");
    function mySubmit() {
        $.ajax({
            url: myFrom.prop("action"),
            type: myFrom.prop("method"),
            data: myFrom.serialize(),
            dataType: "json",
            beforeSend: function () {
                layer.msg("正在提交，请稍后...");
            },
            error: function () {

            },
            complete: function () {

            },
            success: function (data) {
                if (data.State == 400) {
                    layer.msg(data.Msg);
                    return;
                }
                if (data.State == 402) {
                    layer.msg(data.Msg);
                    return;
                }
                else {
                    window.location.href = "/Member/Notice/Create?orderNo=" + data.Msg;
                }
            }
        });
    }
    $(".mySubmit").click(function () {
        return true;
    });

</script>
